import DictTag, { DictValueEnumObj } from "@/components/DictTag";
import { ProDescriptions } from "@ant-design/pro-components";
import { Drawer } from "antd";
import React from "react";
export type OssConfigDetailsProps = {
	onCancel: () => void;
	open: boolean;
	statusOptions: DictValueEnumObj;
	accessPolicyOptions: DictValueEnumObj;
	dataSource: API.System.OssConfigVo | undefined;
	// statusOptions: DictValueEnumObj;
};
const OssConfigDetails: React.FC<OssConfigDetailsProps> = ({
	onCancel = () => {},
	open = false,
	dataSource,
	statusOptions,
	accessPolicyOptions
}) => {
	const columns: any[] = [
		{
			title: "配置键",
			dataIndex: "configKey",
			valueType: "text",
			span: 1
		},

		{
			title: "桶权限",
			dataIndex: "accessPolicy",
			valueType: "select",
			span: 1,
			valueEnum: accessPolicyOptions,
			render: (_, record) => {
				return <DictTag type="tag" enums={accessPolicyOptions} value={record.accessPolicy} />;
			}
		},
		{
			title: "存储桶",
			dataIndex: "bucketName",
			valueType: "text",
			span: 1
		},

		{
			title: "前缀",
			dataIndex: "prefix",
			valueType: "text",
			span: 2
		},
		{
			title: "状态",
			dataIndex: "status",
			valueType: "select",
			span: 2,
			valueEnum: statusOptions,
			render: (_, record) => {
				return <DictTag type="tag" enums={statusOptions} value={record.status} />;
			}
		},
		{
			title: "标识",
			dataIndex: "accessKey",
			valueType: "text",
			span: 2
		},
		{
			title: "秘钥",
			dataIndex: "secretKey",
			valueType: "text",
			span: 2
		},
		{
			title: "端点",
			dataIndex: "endpoint",
			valueType: "text",
			span: 4
		},
		{
			title: "自定义域名",
			dataIndex: "domain",
			valueType: "text",
			span: 4
		},
		{
			title: "区域",
			dataIndex: "region",
			valueType: "text",
			span: 4
		}
	];
	return (
		<>
			<Drawer title="对象存储配置详情" width="50%" placement="right" onClose={onCancel} open={open}>
				<ProDescriptions<API.System.OssConfigVo>
					bordered
					dataSource={dataSource}
					emptyText={"空"}
					columns={columns}
				></ProDescriptions>
			</Drawer>
		</>
	);
};

export default OssConfigDetails;
